﻿// SettingDlg.cpp: 实现文件
//

#include "pch.h"
#include "ProjectAA.h"
#include "SettingDlg.h"
#include "afxdialogex.h"


// CSettingDlg 对话框

IMPLEMENT_DYNAMIC(CSettingDlg, CDialogEx)

CSettingDlg::CSettingDlg(CWnd* pParent /*=nullptr*/)
	: CDialogEx(IDD_DIALOG_SETTING, pParent)
	, m_nPlasmaV(0)
	, m_dPlasmaR(0)
	, m_nGlueV(0)
	, m_dGlueR(0)
	, m_nPlasmaCircleNum(0)
	, m_nGlueCircleNum(0)
	, m_nGlueWait(0)
	, OpenWeight(FALSE)
	, WeightDelay(0)
	, WeightDone(0)
	, WeightUp(0)
	, PlasmaX1(0)
	, PlasmaY1(0)
	, PlasmaZ1(0)
	, PlasmaX2(0)
	, PlasmaY2(0)
	, PlasmaZ2(0)
	, PlasmaX3(0)
	, PlasmaY3(0)
	, PlasmaZ3(0)
	, GlueX1(0)
	, GlueY1(0)
	, GlueZ1(0)
	, GlueX2(0)
	, GlueY2(0)
	, GlueZ2(0)
	, GlueX3(0)
	, GlueY3(0)
	, GlueZ3(0)
	, GlueX4(0)
	, GlueY4(0)
	, GlueZ4(0)
	, GlueX5(0)
	, GlueY5(0)
	, GlueZ5(0)
	, GlueX6(0)
	, GlueY6(0)
	, GlueZ6(0)
	, PassNGBox(FALSE)
	, PassMozu(FALSE)
	, PassJingtou(FALSE)
	, CloseScan(FALSE)
	, m_nPlasmaWait(0)
	, SaveImgFlag(FALSE)
	, SaveResultImgFlag(FALSE)
	, PlasmaX4(0)
	, PlasmaY4(0)
	, PlasmaZ4(0)
	, CheckSpeed(0)
	, CheckDis0(0)
	, CheckDis1(0)
	, CheckDis2(0)
	, CheckSetPos0(0)
	, CheckSetPos1(0)
	, CheckSetPos2(0)
	, PassCheckFlag(FALSE)
	, CheckSNFlag(FALSE)
	, CheckSNLength(0)
	, TanzhenLife(0)
	, OpenNGBaojing(FALSE)
	, m_nPlasmaV_lens(0)
	, m_dPlasmaR_lens(0)
	, m_nPlasmaCircleNum_lens(0)
	, RubGlueStep(0)
	, glueWidthUp(0)
	, glueWidthLow(0)
	, GlueSNCheckFlag(FALSE)
	, GlueSNCheck(_T(""))
	, LgfSNCheck(_T(""))
{

}

CSettingDlg::~CSettingDlg()
{
}

void CSettingDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Text(pDX, IDC_EDIT10, m_nPlasmaV);
	DDX_Text(pDX, IDC_EDIT11, m_dPlasmaR);
	DDX_Text(pDX, IDC_EDIT12, m_nGlueV);
	DDX_Text(pDX, IDC_EDIT13, m_dGlueR);
	DDX_Text(pDX, IDC_EDIT14, m_nPlasmaCircleNum);
	DDX_Text(pDX, IDC_EDIT15, m_nGlueCircleNum);
	DDX_Text(pDX, IDC_EDIT16, m_nGlueWait);
	DDX_Check(pDX, IDC_CHECK3, OpenWeight);
	DDX_Text(pDX, IDC_EDIT1, WeightDelay);
	DDX_Text(pDX, IDC_EDIT2, WeightDone);
	DDX_Text(pDX, IDC_EDIT4, WeightUp);
	DDX_Text(pDX, IDC_POS_X16, PlasmaX1);
	DDX_Text(pDX, IDC_POS_Y16, PlasmaY1);
	DDX_Text(pDX, IDC_POS_Z16, PlasmaZ1);
	DDX_Text(pDX, IDC_POS_X17, PlasmaX2);
	DDX_Text(pDX, IDC_POS_Y17, PlasmaY2);
	DDX_Text(pDX, IDC_POS_Z17, PlasmaZ2);
	DDX_Text(pDX, IDC_POS_X18, PlasmaX3);
	DDX_Text(pDX, IDC_POS_Y18, PlasmaY3);
	DDX_Text(pDX, IDC_POS_Z18, PlasmaZ3);
	DDX_Text(pDX, IDC_POS_X21, GlueX1);
	DDX_Text(pDX, IDC_POS_Y21, GlueY1);
	DDX_Text(pDX, IDC_POS_Z21, GlueZ1);
	DDX_Text(pDX, IDC_POS_X19, GlueX2);
	DDX_Text(pDX, IDC_POS_Y19, GlueY2);
	DDX_Text(pDX, IDC_POS_Z19, GlueZ2);
	DDX_Text(pDX, IDC_POS_X20, GlueX3);
	DDX_Text(pDX, IDC_POS_Y20, GlueY3);
	DDX_Text(pDX, IDC_POS_Z20, GlueZ3);
	DDX_Text(pDX, IDC_POS_X23, GlueX4);
	DDX_Text(pDX, IDC_POS_Y23, GlueY4);
	DDX_Text(pDX, IDC_POS_Z23, GlueZ4);
	DDX_Text(pDX, IDC_POS_X24, GlueX5);
	DDX_Text(pDX, IDC_POS_Y24, GlueY5);
	DDX_Text(pDX, IDC_POS_Z24, GlueZ5);
	DDX_Text(pDX, IDC_POS_X25, GlueX6);
	DDX_Text(pDX, IDC_POS_Y25, GlueY6);
	DDX_Text(pDX, IDC_POS_Z25, GlueZ6);
	DDX_Check(pDX, IDC_CHECK5, PassNGBox);
	DDX_Control(pDX, IDC_COMBO_SPEED, m_comboSpeedMode);
	DDX_Check(pDX, IDC_CHECK6, PassMozu);
	DDX_Check(pDX, IDC_CHECK10, PassJingtou);
	DDX_Check(pDX, IDC_CHECK11, CloseScan);
	DDX_Text(pDX, IDC_EDIT24, m_nPlasmaWait);
	DDX_Check(pDX, IDC_CHECK14, SaveImgFlag);
	DDX_Check(pDX, IDC_CHECK16, SaveResultImgFlag);
	DDX_Text(pDX, IDC_POS_X22, PlasmaX4);
	DDX_Text(pDX, IDC_POS_Y22, PlasmaY4);
	DDX_Text(pDX, IDC_POS_Z22, PlasmaZ4);
	DDX_Text(pDX, IDC_EDIT3, CheckSpeed);
	DDX_Text(pDX, IDC_EDIT31, CheckDis0);
	DDX_Text(pDX, IDC_EDIT32, CheckDis1);
	DDX_Text(pDX, IDC_EDIT33, CheckDis2);
	DDX_Text(pDX, IDC_EDIT34, CheckSetPos0);
	DDX_Text(pDX, IDC_EDIT35, CheckSetPos1);
	DDX_Text(pDX, IDC_EDIT36, CheckSetPos2);
	DDX_Check(pDX, IDC_CHECK17, PassCheckFlag);
	DDX_Check(pDX, IDC_CHECK18, CheckSNFlag);
	DDX_Text(pDX, IDC_EDIT37, CheckSNLength);
	DDX_Text(pDX, IDC_EDIT38, TanzhenLife);
	DDX_Check(pDX, IDC_CHECK19, OpenNGBaojing);
	DDX_Text(pDX, IDC_EDIT39, m_nPlasmaV_lens);
	DDX_Text(pDX, IDC_EDIT40, m_dPlasmaR_lens);
	DDX_Text(pDX, IDC_EDIT41, m_nPlasmaCircleNum_lens);
	DDX_Text(pDX, IDC_EDIT20, RubGlueStep);
	DDX_Text(pDX, IDC_EDIT_GLUEWIDTH_UP, glueWidthUp);
	DDX_Text(pDX, IDC_EDIT_GLUEWIDTH_LOW, glueWidthLow);
	DDX_Check(pDX, IDC_CHECK20, GlueSNCheckFlag);
	DDX_Text(pDX, IDC_EDIT5, GlueSNCheck);
	DDX_Text(pDX, IDC_EDIT6, LgfSNCheck);
}


BEGIN_MESSAGE_MAP(CSettingDlg, CDialogEx)
	ON_BN_CLICKED(IDC_BUTTON_SAVE, &CSettingDlg::OnBnClickedButtonSave)
	ON_BN_CLICKED(IDC_BUTTON1, &CSettingDlg::OnBnClickedButton1)
	ON_BN_CLICKED(IDC_BUTTON2, &CSettingDlg::OnBnClickedButton2)
	ON_BN_CLICKED(IDC_BUTTON3, &CSettingDlg::OnBnClickedButton3)
	ON_BN_CLICKED(IDC_BUTTON4, &CSettingDlg::OnBnClickedButton4)
	ON_BN_CLICKED(IDC_BUTTON5, &CSettingDlg::OnBnClickedButton5)
	ON_BN_CLICKED(IDC_BUTTON6, &CSettingDlg::OnBnClickedButton6)
	ON_BN_CLICKED(IDC_BUTTON26, &CSettingDlg::OnBnClickedButton26)
	ON_BN_CLICKED(IDC_BUTTON27, &CSettingDlg::OnBnClickedButton27)
	ON_BN_CLICKED(IDC_BUTTON28, &CSettingDlg::OnBnClickedButton28)
	ON_BN_CLICKED(IDC_BUTTON7, &CSettingDlg::OnBnClickedButton7)
	ON_BN_CLICKED(IDC_BUTTON_CHECK_GD, &CSettingDlg::OnBnClickedButtonCheckGd)
END_MESSAGE_MAP()


// CSettingDlg 消息处理程序


BOOL CSettingDlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();

	m_comboSpeedMode.ResetContent();
	m_comboSpeedMode.AddString(L"0: 低速");
	m_comboSpeedMode.AddString(L"1: 高速");
	m_comboSpeedMode.SetCurSel(gSystemMgr.SpeedMode);

	ReadConfigIni();

	CWnd* ctrl = GetTopWindow();
	while (ctrl != NULL)
	{
		ctrl->EnableWindow(gSystemMgr.isAdmin ? TRUE : FALSE);
		ctrl = ctrl->GetNextWindow();
	}
	if (!gSystemMgr.isAdmin)
	{
		GetDlgItem(IDC_POS_X16)->EnableWindow(TRUE);
		GetDlgItem(IDC_POS_X17)->EnableWindow(TRUE);
		GetDlgItem(IDC_POS_X18)->EnableWindow(TRUE);
		GetDlgItem(IDC_POS_X22)->EnableWindow(TRUE);
		GetDlgItem(IDC_POS_Y16)->EnableWindow(TRUE);
		GetDlgItem(IDC_POS_Y17)->EnableWindow(TRUE);
		GetDlgItem(IDC_POS_Y18)->EnableWindow(TRUE);
		GetDlgItem(IDC_POS_Y22)->EnableWindow(TRUE);
		GetDlgItem(IDC_POS_Z16)->EnableWindow(TRUE);
		GetDlgItem(IDC_POS_Z17)->EnableWindow(TRUE);
		GetDlgItem(IDC_POS_Z18)->EnableWindow(TRUE);
		GetDlgItem(IDC_POS_Z22)->EnableWindow(TRUE);
		GetDlgItem(IDC_POS_X19)->EnableWindow(TRUE);
		GetDlgItem(IDC_POS_X20)->EnableWindow(TRUE);
		GetDlgItem(IDC_POS_X21)->EnableWindow(TRUE);
		GetDlgItem(IDC_POS_Y19)->EnableWindow(TRUE);
		GetDlgItem(IDC_POS_Y20)->EnableWindow(TRUE);
		GetDlgItem(IDC_POS_Y21)->EnableWindow(TRUE);
		GetDlgItem(IDC_POS_Z19)->EnableWindow(TRUE);
		GetDlgItem(IDC_POS_Z20)->EnableWindow(TRUE);
		GetDlgItem(IDC_POS_Z21)->EnableWindow(TRUE);;
		GetDlgItem(IDC_POS_X23)->EnableWindow(TRUE);
		GetDlgItem(IDC_POS_X24)->EnableWindow(TRUE);
		GetDlgItem(IDC_POS_X25)->EnableWindow(TRUE);
		GetDlgItem(IDC_POS_Y23)->EnableWindow(TRUE);
		GetDlgItem(IDC_POS_Y24)->EnableWindow(TRUE);
		GetDlgItem(IDC_POS_Y25)->EnableWindow(TRUE);
		GetDlgItem(IDC_POS_Z23)->EnableWindow(TRUE);
		GetDlgItem(IDC_POS_Z24)->EnableWindow(TRUE);
		GetDlgItem(IDC_POS_Z25)->EnableWindow(TRUE);
		GetDlgItem(IDC_EDIT_MES_GD)->EnableWindow(TRUE);
		GetDlgItem(IDC_BUTTON_CHECK_GD)->EnableWindow(TRUE);
		GetDlgItem(IDC_BUTTON_SAVE)->EnableWindow(TRUE);

		GetDlgItem(IDC_BUTTON1)->EnableWindow(TRUE);
		GetDlgItem(IDC_BUTTON2)->EnableWindow(TRUE);
		GetDlgItem(IDC_BUTTON3)->EnableWindow(TRUE);
		GetDlgItem(IDC_BUTTON4)->EnableWindow(TRUE);
		GetDlgItem(IDC_BUTTON5)->EnableWindow(TRUE);
		GetDlgItem(IDC_BUTTON6)->EnableWindow(TRUE);
		GetDlgItem(IDC_BUTTON26)->EnableWindow(TRUE);
		GetDlgItem(IDC_BUTTON27)->EnableWindow(TRUE);
		GetDlgItem(IDC_BUTTON28)->EnableWindow(TRUE);
		GetDlgItem(IDC_BUTTON10)->EnableWindow(TRUE);
	}

	return TRUE;
}


void CSettingDlg::OnCancel()
{
	// TODO: 在此添加专用代码和/或调用基类

	CDialogEx::OnCancel();
}

void CSettingDlg::ReadConfigIni()
{
	PlasmaX1 = gSystemMgr.PlasmaX[0];
	PlasmaY1 = gSystemMgr.PlasmaY[0];
	PlasmaZ1 = gSystemMgr.PlasmaZ[0];
	PlasmaX2 = gSystemMgr.PlasmaX[1];
	PlasmaY2 = gSystemMgr.PlasmaY[1];
	PlasmaZ2 = gSystemMgr.PlasmaZ[1];
	PlasmaX3 = gSystemMgr.PlasmaX[2];
	PlasmaY3 = gSystemMgr.PlasmaY[2];
	PlasmaZ3 = gSystemMgr.PlasmaZ[2];
	PlasmaX4 = gSystemMgr.PlasmaX[3];
	PlasmaY4 = gSystemMgr.PlasmaY[3];
	PlasmaZ4 = gSystemMgr.PlasmaZ[3];

	GlueX1 = gSystemMgr.GlueX[0];
	GlueY1 = gSystemMgr.GlueY[0];
	GlueZ1 = gSystemMgr.GlueZ[0];
	GlueX2 = gSystemMgr.GlueX[1];
	GlueY2 = gSystemMgr.GlueY[1];
	GlueZ2 = gSystemMgr.GlueZ[1];
	GlueX3 = gSystemMgr.GlueX[2];
	GlueY3 = gSystemMgr.GlueY[2];
	GlueZ3 = gSystemMgr.GlueZ[2];

	GlueX4 = gSystemMgr.GlueX[3];
	GlueY4 = gSystemMgr.GlueY[3];
	GlueZ4 = gSystemMgr.GlueZ[3];
	GlueX5 = gSystemMgr.GlueX[4];
	GlueY5 = gSystemMgr.GlueY[4];
	GlueZ5 = gSystemMgr.GlueZ[4];
	GlueX6 = gSystemMgr.GlueX[5];
	GlueY6 = gSystemMgr.GlueY[5];
	GlueZ6 = gSystemMgr.GlueZ[5];

	CheckSetPos0 = gSystemMgr.CheckSetPos[0];
	CheckSetPos1 = gSystemMgr.CheckSetPos[1];
	CheckSetPos2 = gSystemMgr.CheckSetPos[2];
	CheckDis0 = gSystemMgr.CheckDis[0];
	CheckDis1 = gSystemMgr.CheckDis[1];
	CheckDis2 = gSystemMgr.CheckDis[2];
	CheckSpeed = gSystemMgr.CheckSpeed;
	PassCheckFlag = gSystemMgr.PassCheckFlag;

	m_nPlasmaV = gSystemMgr.m_nPlasmaV;
	m_dPlasmaR = gSystemMgr.m_dPlasmaR;
	m_nPlasmaCircleNum = gSystemMgr.m_nPlasmaCircleNum;
	m_nPlasmaWait = gSystemMgr.m_nPlasmaWait;

	m_nPlasmaV_lens = gSystemMgr.m_nPlasmaV_lens;
	m_dPlasmaR_lens = gSystemMgr.m_dPlasmaR_lens;
	m_nPlasmaCircleNum_lens = gSystemMgr.m_nPlasmaCircleNum_lens;

	m_nGlueV = gSystemMgr.m_nGlueV;
	m_dGlueR = gSystemMgr.m_dGlueR;
	m_nGlueCircleNum = gSystemMgr.m_nGlueCircleNum;
	m_nGlueWait = gSystemMgr.m_nGlueWait;
	glueWidthUp = gSystemMgr.glueWidthUp;
	glueWidthLow = gSystemMgr.glueWidthLow;

	OpenWeight = gSystemMgr.OpenWeight;
	WeightDelay = gSystemMgr.WeightDelay;
	WeightDone = gSystemMgr.WeightDone;
	WeightUp = gSystemMgr.WeightUp;

	PassNGBox = gSystemMgr.PassNGBox;
	PassMozu = gSystemMgr.PassMozu;
	PassJingtou = gSystemMgr.PassJingtou;
	CloseScan = gSystemMgr.CloseScan;

	SaveImgFlag = gSystemMgr.SaveImgFlag;
	SaveResultImgFlag = gSystemMgr.SaveResultImgFlag;

	CheckSNFlag = gSystemMgr.CheckSNFlag;
	CheckSNLength = gSystemMgr.CheckSNLength;

	TanzhenLife = gSystemMgr.TanzhenLifeSpec;

	OpenNGBaojing = gSystemMgr.OpenNGBaojing;

	RubGlueStep = gSystemMgr.RubGlueStep;

	GlueSNCheckFlag = gSystemMgr.GlueSNCheckFlag;
	GlueSNCheck = gSystemMgr.GlueSNCheck;
	LgfSNCheck = gSystemMgr.LgfSNCheck;

	UpdateData(FALSE);

	((CButton*)(GetDlgItem(IDC_CHECK_IS_OPEN_MES)))->SetCheck(gSystemMgr.MesFlag);
	SetDlgItemText(IDC_EDIT_MES_IP, gSystemMgr.m_cstrIPMes);
	SetDlgItemInt(IDC_EDIT_MES_PORT, gSystemMgr.m_nPortMes);
	SetDlgItemText(IDC_EDIT_MES_WPCODE, gSystemMgr.st10wp_code);
	SetDlgItemText(IDC_EDIT_MES_WPCODE2, gSystemMgr.st20wp_code);
	SetDlgItemText(IDC_EDIT_MES_GD, gSystemMgr.gdNo);
}

void CSettingDlg::SaveEditValueToConfig()
{
	UpdateData(TRUE);
	CString cstr;
	gSystemMgr.PlasmaX[0] = PlasmaX1;
	gSystemMgr.PlasmaY[0] = PlasmaY1;
	gSystemMgr.PlasmaZ[0] = PlasmaZ1;
	gSystemMgr.PlasmaX[1] = PlasmaX2;
	gSystemMgr.PlasmaY[1] = PlasmaY2;
	gSystemMgr.PlasmaZ[1] = PlasmaZ2;
	gSystemMgr.PlasmaX[2] = PlasmaX3;
	gSystemMgr.PlasmaY[2] = PlasmaY3;
	gSystemMgr.PlasmaZ[2] = PlasmaZ3;
	gSystemMgr.PlasmaX[3] = PlasmaX4;
	gSystemMgr.PlasmaY[3] = PlasmaY4;
	gSystemMgr.PlasmaZ[3] = PlasmaZ4;

	gSystemMgr.GlueX[0] = GlueX1;
	gSystemMgr.GlueY[0] = GlueY1;
	gSystemMgr.GlueZ[0] = GlueZ1;
	gSystemMgr.GlueX[1] = GlueX2;
	gSystemMgr.GlueY[1] = GlueY2;
	gSystemMgr.GlueZ[1] = GlueZ2;
	gSystemMgr.GlueX[2] = GlueX3;
	gSystemMgr.GlueY[2] = GlueY3;
	gSystemMgr.GlueZ[2] = GlueZ3;
	gSystemMgr.GlueX[3] = GlueX4;
	gSystemMgr.GlueY[3] = GlueY4;
	gSystemMgr.GlueZ[3] = GlueZ4;
	gSystemMgr.GlueX[4] = GlueX5;
	gSystemMgr.GlueY[4] = GlueY5;
	gSystemMgr.GlueZ[4] = GlueZ5;
	gSystemMgr.GlueX[5] = GlueX6;
	gSystemMgr.GlueY[5] = GlueY6;
	gSystemMgr.GlueZ[5] = GlueZ6;



	gSystemMgr.CheckSetPos[0] = CheckSetPos0;
	gSystemMgr.CheckSetPos[1] = CheckSetPos1;
	gSystemMgr.CheckSetPos[2] = CheckSetPos2;
	gSystemMgr.CheckDis[0] = CheckDis0;
	gSystemMgr.CheckDis[1] = CheckDis1;
	gSystemMgr.CheckDis[2] = CheckDis2;
	gSystemMgr.CheckSpeed = CheckSpeed;
	gSystemMgr.PassCheckFlag = PassCheckFlag;

	gSystemMgr.m_nPlasmaV = m_nPlasmaV;
	gSystemMgr.m_dPlasmaR = m_dPlasmaR;
	gSystemMgr.m_nPlasmaCircleNum = m_nPlasmaCircleNum;
	gSystemMgr.m_nPlasmaWait = m_nPlasmaWait;

	gSystemMgr.m_nPlasmaV_lens = m_nPlasmaV_lens;
	gSystemMgr.m_dPlasmaR_lens = m_dPlasmaR_lens;
	gSystemMgr.m_nPlasmaCircleNum_lens = m_nPlasmaCircleNum_lens;

	gSystemMgr.m_nGlueV = m_nGlueV;
	gSystemMgr.m_dGlueR = m_dGlueR;
	gSystemMgr.m_nGlueCircleNum = m_nGlueCircleNum;
	gSystemMgr.m_nGlueWait = m_nGlueWait;
	gSystemMgr.glueWidthUp = glueWidthUp;
	gSystemMgr.glueWidthLow = glueWidthLow;

	gSystemMgr.OpenWeight = OpenWeight;
	gSystemMgr.WeightDelay = WeightDelay;
	gSystemMgr.WeightDone = WeightDone;
	gSystemMgr.WeightUp = WeightUp;

	gSystemMgr.PassNGBox = PassNGBox;
	gSystemMgr.PassMozu = PassMozu;
	gSystemMgr.PassJingtou = PassJingtou;
	gSystemMgr.CloseScan = CloseScan;

	gSystemMgr.SpeedMode = m_comboSpeedMode.GetCurSel();

	gSystemMgr.SaveImgFlag = SaveImgFlag;
	gSystemMgr.SaveResultImgFlag = SaveResultImgFlag;

	gSystemMgr.CheckSNFlag = CheckSNFlag;
	gSystemMgr.CheckSNLength = CheckSNLength;

	gSystemMgr.TanzhenLifeSpec = TanzhenLife;

	gSystemMgr.OpenNGBaojing = OpenNGBaojing;

	gSystemMgr.RubGlueStep = RubGlueStep;


	// mes
	gSystemMgr.MesFlag = ((CButton*)(GetDlgItem(IDC_CHECK_IS_OPEN_MES)))->GetCheck();
	GetDlgItemText(IDC_EDIT_MES_IP, gSystemMgr.m_cstrIPMes);
	gSystemMgr.m_nPortMes = GetDlgItemInt(IDC_EDIT_MES_PORT);
	GetDlgItemText(IDC_EDIT_MES_WPCODE, gSystemMgr.st10wp_code);
	GetDlgItemText(IDC_EDIT_MES_WPCODE2, gSystemMgr.st20wp_code);
	GetDlgItemText(IDC_EDIT_MES_GD, gSystemMgr.gdNo);




	cstr.Format(L"%d", gSystemMgr.RubGlueStep); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"RubGlueStep", cstr);

	cstr.Format(L"%d", gSystemMgr.OpenNGBaojing); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"OpenNGBaojing", cstr);

	cstr.Format(L"%d", gSystemMgr.TanzhenLifeSpec); gSystemMgr.m_cGeneralSetting.SaveConfigIni(L"GeneralSetting", L"TanzhenLifeSpec", cstr);

	cstr.Format(L"%d", gSystemMgr.CheckSNFlag); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"CheckSNFlag", cstr);
	cstr.Format(L"%d", gSystemMgr.CheckSNLength); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"CheckSNLength", cstr);

	cstr.Format(L"%d", gSystemMgr.SaveImgFlag); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"SaveImgFlag", cstr);
	cstr.Format(L"%d", gSystemMgr.SaveResultImgFlag); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"SaveResultImgFlag", cstr);

	cstr.Format(L"%d", gSystemMgr.SpeedMode); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"SpeedMode", cstr);

	cstr.Format(L"%d", gSystemMgr.PlasmaX[0]); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"PlasmaX[0]", cstr);
	cstr.Format(L"%d", gSystemMgr.PlasmaY[0]); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"PlasmaY[0]", cstr);
	cstr.Format(L"%d", gSystemMgr.PlasmaZ[0]); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"PlasmaZ[0]", cstr);
	cstr.Format(L"%d", gSystemMgr.PlasmaX[1]); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"PlasmaX[1]", cstr);
	cstr.Format(L"%d", gSystemMgr.PlasmaY[1]); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"PlasmaY[1]", cstr);
	cstr.Format(L"%d", gSystemMgr.PlasmaZ[1]); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"PlasmaZ[1]", cstr);
	cstr.Format(L"%d", gSystemMgr.PlasmaX[2]); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"PlasmaX[2]", cstr);
	cstr.Format(L"%d", gSystemMgr.PlasmaY[2]); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"PlasmaY[2]", cstr);
	cstr.Format(L"%d", gSystemMgr.PlasmaZ[2]); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"PlasmaZ[2]", cstr);
	cstr.Format(L"%d", gSystemMgr.PlasmaX[3]); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"PlasmaX[3]", cstr);
	cstr.Format(L"%d", gSystemMgr.PlasmaY[3]); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"PlasmaY[3]", cstr);
	cstr.Format(L"%d", gSystemMgr.PlasmaZ[3]); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"PlasmaZ[3]", cstr);

	cstr.Format(L"%d", gSystemMgr.GlueX[0]); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"GlueX[0]", cstr);
	cstr.Format(L"%d", gSystemMgr.GlueY[0]); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"GlueY[0]", cstr);
	cstr.Format(L"%d", gSystemMgr.GlueZ[0]); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"GlueZ[0]", cstr);
	cstr.Format(L"%d", gSystemMgr.GlueX[1]); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"GlueX[1]", cstr);
	cstr.Format(L"%d", gSystemMgr.GlueY[1]); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"GlueY[1]", cstr);
	cstr.Format(L"%d", gSystemMgr.GlueZ[1]); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"GlueZ[1]", cstr);
	cstr.Format(L"%d", gSystemMgr.GlueX[2]); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"GlueX[2]", cstr);
	cstr.Format(L"%d", gSystemMgr.GlueY[2]); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"GlueY[2]", cstr);
	cstr.Format(L"%d", gSystemMgr.GlueZ[2]); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"GlueZ[2]", cstr);
	cstr.Format(L"%d", gSystemMgr.GlueX[3]); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"GlueX[3]", cstr);
	cstr.Format(L"%d", gSystemMgr.GlueY[3]); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"GlueY[3]", cstr);
	cstr.Format(L"%d", gSystemMgr.GlueZ[3]); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"GlueZ[3]", cstr);
	cstr.Format(L"%d", gSystemMgr.GlueX[4]); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"GlueX[4]", cstr);
	cstr.Format(L"%d", gSystemMgr.GlueY[4]); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"GlueY[4]", cstr);
	cstr.Format(L"%d", gSystemMgr.GlueZ[4]); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"GlueZ[4]", cstr);
	cstr.Format(L"%d", gSystemMgr.GlueX[5]); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"GlueX[5]", cstr);
	cstr.Format(L"%d", gSystemMgr.GlueY[5]); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"GlueY[5]", cstr);
	cstr.Format(L"%d", gSystemMgr.GlueZ[5]); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"GlueZ[5]", cstr);
	cstr.Format(L"%f", gSystemMgr.glueWidthUp); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"glueWidthUp", cstr);
	cstr.Format(L"%f", gSystemMgr.glueWidthLow); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"glueWidthLow", cstr);

	cstr.Format(L"%d", gSystemMgr.CheckSetPos[0]); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"CheckSetPos[0]", cstr);
	cstr.Format(L"%d", gSystemMgr.CheckSetPos[1]); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"CheckSetPos[1]", cstr);
	cstr.Format(L"%d", gSystemMgr.CheckSetPos[2]); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"CheckSetPos[2]", cstr);
	cstr.Format(L"%d", gSystemMgr.CheckDis[0]); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"CheckDis[0]", cstr);
	cstr.Format(L"%d", gSystemMgr.CheckDis[1]); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"CheckDis[1]", cstr);
	cstr.Format(L"%d", gSystemMgr.CheckDis[2]); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"CheckDis[2]", cstr);
	cstr.Format(L"%d", gSystemMgr.CheckSpeed); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"CheckSpeed", cstr);
	cstr.Format(L"%d", gSystemMgr.PassCheckFlag); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"PassCheckFlag", cstr);

	cstr.Format(L"%d", gSystemMgr.m_nPlasmaV); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"m_nPlasmaV", cstr);
	cstr.Format(L"%.4f", gSystemMgr.m_dPlasmaR); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"m_dPlasmaR", cstr);
	cstr.Format(L"%d", gSystemMgr.m_nPlasmaCircleNum); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"m_nPlasmaCircleNum", cstr);
	cstr.Format(L"%d", gSystemMgr.m_nPlasmaWait); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"m_nPlasmaWait", cstr);

	cstr.Format(L"%d", gSystemMgr.m_nPlasmaV_lens); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"m_nPlasmaV_lens", cstr);
	cstr.Format(L"%.4f", gSystemMgr.m_dPlasmaR_lens); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"m_dPlasmaR_lens", cstr);
	cstr.Format(L"%d", gSystemMgr.m_nPlasmaCircleNum_lens); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"m_nPlasmaCircleNum_lens", cstr);

	cstr.Format(L"%d", gSystemMgr.m_nGlueV); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"m_nGlueV", cstr);
	cstr.Format(L"%.4f", gSystemMgr.m_dGlueR); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"m_dGlueR", cstr);
	cstr.Format(L"%d", gSystemMgr.m_nGlueCircleNum); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"m_nGlueCircleNum", cstr);
	cstr.Format(L"%d", gSystemMgr.m_nGlueWait); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"m_nGlueWait", cstr);

	cstr.Format(L"%d", gSystemMgr.OpenWeight); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"OpenWeight", cstr);
	cstr.Format(L"%.4f", gSystemMgr.WeightDelay); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"WeightDelay", cstr);
	cstr.Format(L"%.4f", gSystemMgr.WeightDone); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"WeightDone", cstr);
	cstr.Format(L"%.4f", gSystemMgr.WeightUp); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"WeightUp", cstr);

	cstr.Format(L"%d", gSystemMgr.PassNGBox); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"PassNGBox", cstr);
	cstr.Format(L"%d", gSystemMgr.PassMozu); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"PassMozu", cstr);
	cstr.Format(L"%d", gSystemMgr.PassJingtou); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"PassJingtou", cstr);
	cstr.Format(L"%d", gSystemMgr.CloseScan); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"CloseScan", cstr);

	gSystemMgr.GlueSNCheckFlag = GlueSNCheckFlag;
	cstr.Format(L"%d", gSystemMgr.GlueSNCheckFlag); gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"GlueSNCheckFlag", cstr);
	gSystemMgr.GlueSNCheck = GlueSNCheck;
	gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"GlueSNCheck", GlueSNCheck);
	gSystemMgr.LgfSNCheck = LgfSNCheck;
	gSystemMgr.m_cPosConfigIni.SaveConfigIni(L"PosConfig", L"LgfSNCheck", LgfSNCheck);


	cstr.Format(L"%d", gSystemMgr.MesFlag);
	gSystemMgr.m_cMesConfigIni.SaveConfigIni(L"MES", L"MesFlag", cstr);
	cstr.Format(L"%d", gSystemMgr.m_nPortMes);
	gSystemMgr.m_cMesConfigIni.SaveConfigIni(L"MES", L"m_nPortMes", cstr);

	gSystemMgr.m_cMesConfigIni.SaveConfigIni(L"MES", L"m_cstrIPMes", gSystemMgr.m_cstrIPMes);
	gSystemMgr.m_cMesConfigIni.SaveConfigIni(L"MES", L"st10wp_code", gSystemMgr.st10wp_code);
	gSystemMgr.m_cMesConfigIni.SaveConfigIni(L"MES", L"st20wp_code", gSystemMgr.st20wp_code);
	gSystemMgr.m_cMesConfigIni.SaveConfigIni(L"MES", L"gdNo", gSystemMgr.gdNo);

}

void CSettingDlg::OnBnClickedButtonSave()
{
	SaveEditValueToConfig();
}


void CSettingDlg::OnBnClickedButton1()
{
	//设定夹取位置
	if (IDYES == AfxMessageBox(L"确定 设定当前位置为Plasma待机位置 吗？", MB_YESNO))
	{
		PlasmaX1 = gSystemMgr.m_vCMotor[MOTOR_X1].m_nCurPositon;
		PlasmaY1 = gSystemMgr.m_vCMotor[MOTOR_Y1].m_nCurPositon;
		PlasmaZ1 = gSystemMgr.m_vCMotor[MOTOR_Z1].m_nCurPositon;

		UpdateData(FALSE);
	}
}


void CSettingDlg::OnBnClickedButton2()
{
	if (IDYES == AfxMessageBox(L"确定 设定当前位置为模组Plasma位置 吗？", MB_YESNO))
	{
		PlasmaX2 = gSystemMgr.m_vCMotor[MOTOR_X1].m_nCurPositon;
		PlasmaY2 = gSystemMgr.m_vCMotor[MOTOR_Y1].m_nCurPositon;
		PlasmaZ2 = gSystemMgr.m_vCMotor[MOTOR_Z1].m_nCurPositon;

		UpdateData(FALSE);
	}
}


void CSettingDlg::OnBnClickedButton3()
{
	if (IDYES == AfxMessageBox(L"确定 设定当前位置为镜头Plasma位置 吗？", MB_YESNO))
	{
		PlasmaX3 = gSystemMgr.m_vCMotor[MOTOR_X1].m_nCurPositon;
		PlasmaY3 = gSystemMgr.m_vCMotor[MOTOR_Y1].m_nCurPositon;
		PlasmaZ3 = gSystemMgr.m_vCMotor[MOTOR_Z1].m_nCurPositon;

		UpdateData(FALSE);
	}
}


void CSettingDlg::OnBnClickedButton4()
{
	//设定夹取位置
	if (IDYES == AfxMessageBox(L"确定 设定当前位置为点胶待机位置 吗？", MB_YESNO))
	{
		GlueX1 = gSystemMgr.m_vCMotor[MOTOR_X2].m_nCurPositon;
		GlueY1 = gSystemMgr.m_vCMotor[MOTOR_Y2].m_nCurPositon;
		GlueZ1 = gSystemMgr.m_vCMotor[MOTOR_Z2].m_nCurPositon;

		UpdateData(FALSE);
	}
}


void CSettingDlg::OnBnClickedButton5()
{
	if (IDYES == AfxMessageBox(L"确定 设定当前位置为点胶起点 吗？", MB_YESNO))
	{
		GlueX2 = gSystemMgr.m_vCMotor[MOTOR_X2].m_nCurPositon;
		GlueY2 = gSystemMgr.m_vCMotor[MOTOR_Y2].m_nCurPositon;
		GlueZ2 = gSystemMgr.m_vCMotor[MOTOR_Z2].m_nCurPositon;

		UpdateData(FALSE);
	}
}


void CSettingDlg::OnBnClickedButton6()
{
	if (IDYES == AfxMessageBox(L"确定 设定当前位置为点胶称重位 吗？", MB_YESNO))
	{
		GlueX3 = gSystemMgr.m_vCMotor[MOTOR_X2].m_nCurPositon;
		GlueY3 = gSystemMgr.m_vCMotor[MOTOR_Y2].m_nCurPositon;
		GlueZ3 = gSystemMgr.m_vCMotor[MOTOR_Z2].m_nCurPositon;

		UpdateData(FALSE);
	}
}


void CSettingDlg::OnBnClickedButton26()
{
	if (IDYES == AfxMessageBox(L"确定 设定当前位置为 X方向对针起点 吗？", MB_YESNO))
	{
		GlueX4 = gSystemMgr.m_vCMotor[MOTOR_X2].m_nCurPositon;
		GlueY4 = gSystemMgr.m_vCMotor[MOTOR_Y2].m_nCurPositon;
		GlueZ4 = gSystemMgr.m_vCMotor[MOTOR_Z2].m_nCurPositon;

		UpdateData(FALSE);
	}
}


void CSettingDlg::OnBnClickedButton27()
{
	if (IDYES == AfxMessageBox(L"确定 设定当前位置为 Y方向对针起点 吗？", MB_YESNO))
	{
		GlueX5 = gSystemMgr.m_vCMotor[MOTOR_X2].m_nCurPositon;
		GlueY5 = gSystemMgr.m_vCMotor[MOTOR_Y2].m_nCurPositon;
		GlueZ5 = gSystemMgr.m_vCMotor[MOTOR_Z2].m_nCurPositon;

		UpdateData(FALSE);
	}
}


void CSettingDlg::OnBnClickedButton28()
{
	if (IDYES == AfxMessageBox(L"确定 设定当前位置为 Z方向对针起点 吗？", MB_YESNO))
	{
		GlueX6 = gSystemMgr.m_vCMotor[MOTOR_X2].m_nCurPositon;
		GlueY6 = gSystemMgr.m_vCMotor[MOTOR_Y2].m_nCurPositon;
		GlueZ6 = gSystemMgr.m_vCMotor[MOTOR_Z2].m_nCurPositon;

		UpdateData(FALSE);
	}
}


void CSettingDlg::OnBnClickedButton7()
{
	if (IDYES == AfxMessageBox(L"确定 清零当前探针使用次数 吗？", MB_YESNO))
	{
		gSystemMgr.TanzhenLife = 0;
		CString cstr;
		cstr.Format(L"%d", gSystemMgr.TanzhenLife); gSystemMgr.m_cGeneralSetting.SaveConfigIni(L"GeneralSetting", L"TanzhenLife", cstr);
	}
}


void CSettingDlg::OnBnClickedButtonCheckGd()
{
	CString gd = L"";
	GetDlgItemText(IDC_EDIT_MES_GD, gd);
	USES_CONVERSION;
	bool v = gSystemMgr.MesCheckGD(T2A(gd));
	if (v)
	{
		MessageBox(L"工单OK", L"校验工单");
	}
	else
	{
		MessageBox(L"工单NG", L"校验工单", MB_ICONERROR);
	}
}
